<template>
  <footer class="footer">
      <span class="todo-count">剩余<strong>{{surplusCount}}</strong></span>
      <ul class="filters" @click="$emit('changeType',type)">
        <li>
          <a :class="{selected:type==='all'}" href="#/"
           @click.prevent="type='all'"
           >全部</a>
        </li>
        <li>
          <a href="#/active" 
          @click.prevent=" type = 'active'"
          :class="{selected:type==='active'}"
          >进行中</a>
        </li>
        <li>
          <a href="#/completed" @click.prevent="type='completed'"
           :class="{selected:type==='completed'}"
          >已完成</a>
        </li>
      </ul>
      <button class="clear-completed" 
      v-show="surplusCount!==list.length"
      @click="clearDone"
      >清除已完成</button>
    </footer>
</template>

<script>
export default {
  props:{
    list:{
      required:true,
      type:Array
    }
  },
  data() {
    return {
     type:'all'
    }
  },
  computed:{
    surplusCount(){
       return (this.list.filter(item=>!item.isDone)).length
    }
  },
  methods:{
    clearDone(){
      this.$emit('clearDone')
    },
  
  }
}
</script>